package com.nbicc.dp.web.widget.controller;

import com.nbicc.core.common.RequestPageObj;
import com.nbicc.db.modular.dp.widget.model.WidgetClass;
import com.nbicc.service.modular.dp.widget.service.WidgetClassService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import java.util.Map;

/**
 * @Author: lilingyan
 */
@Api(value = "dp:组件类" , description = "")
@RestController
@RequestMapping("/widget/class")
public class WidgetClassController {

    @Autowired
    private WidgetClassService widgetClassService;

    @ApiOperation(value = "按id查询")
    @GetMapping("/{id:.+}")
    public ResponseEntity<ModelMap> selectBySerialNum(@PathVariable String id){
        return widgetClassService.selectById(id);
    }

    @ApiOperation(value = "分页查询")
    @PostMapping("/find")
    public ResponseEntity<ModelMap> find(@RequestBody RequestPageObj<Map<String,Object>> requestPageObj){
        return widgetClassService.find(requestPageObj);
    }

    @ApiOperation(value = "添加" , notes = "id自动生成")
    @PostMapping
    public ResponseEntity<ModelMap> insert(@RequestBody WidgetClass widgetClass){
        return widgetClassService.insert(widgetClass);
    }

    @ApiOperation(value = "修改", notes = "以id修改(必传)")
    @PutMapping
    public ResponseEntity<ModelMap> updateById(@RequestBody WidgetClass widgetClass){
        return widgetClassService.updateById(widgetClass);
    }

    @ApiOperation(value = "删除", notes = "")
    @DeleteMapping("/{id:.+}")
    public ResponseEntity<ModelMap> deleteById(@PathVariable String id){
        return widgetClassService.deleteById(id);
    }

}
